<?php
$arr = array(
	array(
		"id"=>"1",
		"value"=>21
	),
	array(
		"id"=>"2",
		"value"=>22
	),
	array(
		"id"=>"4",
		"value"=>23
	)

);

$arr2 = array(
	array(
		"id"=>"1",
		"sex"=>'man'
	),
	array(
		"id"=>"2",
		"sex"=>'woman'
	),
	array(
		"id"=>"3",
		"sex"=>'woman'
	)
);

//方法一
foreach ($arr as $key => $value) {
	foreach ($arr2 as  $value2) {
		if($value['id'] == $value2['id']){
			$arr[$key] = $value + $value2;
		}
	}
}

print_r($arr);exit;


//方法二
// $ids = array();

// foreach ($arr as $k => $v){
// 	$arr['id:'.$v['id']] = $v;
// 	unset($arr[$k]);
// 	$ids[] = $v['id'];
// }


// foreach ($arr2 as $k => $v){
// 	$arr2['id:'.$v['id']] = $v;
// 	unset($arr2[$k]);
// 	$ids[] = $v['id'];
// }

// $ids = array_unique($ids);

// foreach($ids as $id){
// 	empty($arr['id:'.$id]) && $arr['id:'.$id] = array();
// 	empty($arr2['id:'.$id]) && $arr2['id:'.$id] = array();
// 	$arr[$id] = $arr['id:'.$id] + $arr2['id:'.$id];
// 	unset($arr['id:'.$id]);
// }


// print_r($arr);exit;


// $arr1 = array(
// 		'name' => 'yanghongwei',
// 		'sex' => 'male',
// 		'addr' => 'shanxi',
// 	);

// $arr2 = array(
// 		'name' => 'baiyu',
// 		'sex' => 'man',
// 		'tel' => '10086',
// 	);

// print_r($arr1 + $arr2);

// echo "-------------\n";

// print_r(array_merge($arr1, $arr2));
